package com.umeox.watch.moto.dataservice.mqtt.request;

import com.alibaba.fastjson.JSONObject;
import com.umeox.moto.mqtt.request.MqttPublishRequest;
import com.umeox.watch.moto.dataservice.base.BaseApp;


public class EventRequest extends MqttPublishRequest {

    public EventRequest(String topic, String event, Object data) {

        this.requestId = BaseApp.getInstance().createRequestId();

        JSONObject temp = new JSONObject();
        temp.put("method", event);
        temp.put("params", data);
        this.topic = topic + requestId;
        this.qos = 0;
        this.replyTopic = topic.substring(0,topic.lastIndexOf("/")) + "_reply/" + requestId;
        this.payloadObj = temp.toString();
    }

}
